package TreeSet;

public class Student implements Comparable<Student> {
    String name;
    int age;
    int chinese;
    int english;
    int math;

    public Student() {
    }

    public Student(String name, int age, int chinese, int english, int math) {
        this.name = name;
        this.age = age;
        this.chinese = chinese;
        this.english = english;
        this.math = math;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return age
     */
    public int getAge() {
        return age;
    }

    /**
     * 设置
     * @param age
     */
    public void setAge(int age) {
        this.age = age;
    }

    /**
     * 获取
     * @return chinese
     */
    public int getChinese() {
        return chinese;
    }

    /**
     * 设置
     * @param chinese
     */
    public void setChinese(int chinese) {
        this.chinese = chinese;
    }

    /**
     * 获取
     * @return english
     */
    public int getEnglish() {
        return english;
    }

    /**
     * 设置
     * @param english
     */
    public void setEnglish(int english) {
        this.english = english;
    }

    /**
     * 获取
     * @return math
     */
    public int getMath() {
        return math;
    }

    /**
     * 设置
     * @param math
     */
    public void setMath(int math) {
        this.math = math;
    }

    public String toString() {
        return "Student{name = " + name + ", age = " + age + ", chinese = " + chinese + ", english = " + english + ", math = " + math + "}";
    }

    @Override
    public int compareTo(Student o) {
       int sum1 =0;
       int sum2 =0;
       sum1 = this.chinese+this.english+this.math;
       sum2 = o.getChinese()+o.getEnglish()+o.getMath();
       int i =sum1-sum2;
       i=i==0?this.getChinese()-o.chinese:i;

        return i;
    }
}
